package com.blog.controller.frontpage;

import java.io.IOException;
import java.sql.Timestamp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blog.controller.base.BaseServlet;
import com.blog.entity.DiscussEntity;
import com.blog.service.frontpage.PersonalCenterService;

@WebServlet("/personalcenter/postcoment")
public class PostCommentServlet extends BaseServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		PersonalCenterService service=PersonalCenterService.getInstance();
		DiscussEntity e=new DiscussEntity();
		int discuss_id=Integer.parseInt(req.getParameter("discuss_id"));
		
		int article_id=Integer.parseInt(req.getParameter("article_id"));
		String discuss_content=req.getParameter("discuss_content");
		Timestamp discuss_time=new Timestamp(Long.parseLong(req.getParameter("discuss_time")));
		e.setArticle_id(article_id);
		e.setDiscuss_content(discuss_content);
		e.setDiscuss_id(discuss_id);
		e.setDiscuss_time(discuss_time);
		service.saveComent(e);
		
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
}